<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<title>PhysiTrack: D:/physi-tracklast/01/Android/PhysiTrack/src/helper/FileIOHelper.java Source File</title>

<link href="tabs.css" rel="stylesheet" type="text/css"/>
<link href="doxygen.css" rel="stylesheet" type="text/css" />

<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="search/search.js"></script>
<script type="text/javascript">
  $(document).ready(function() { searchBox.OnSelectItem(0); });
</script>

</head>
<body>
<div id="top"><!-- do not remove this div! -->


<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  
  
  <td style="padding-left: 0.5em;">
   <div id="projectname">PhysiTrack
   
   </div>
   
  </td>
  
  
  
 </tr>
 </tbody>
</table>
</div>

<!-- Generated by Doxygen 1.8.0 -->
<script type="text/javascript">
var searchBox = new SearchBox("searchBox", "search",false,'Search');
</script>
  <div id="navrow1" class="tabs">
    <ul class="tablist">
      <li><a href="index.html"><span>Main&#160;Page</span></a></li>
      <li><a href="namespaces.html"><span>Packages</span></a></li>
      <li><a href="annotated.html"><span>Classes</span></a></li>
      <li class="current"><a href="files.html"><span>Files</span></a></li>
      <li>
        <div id="MSearchBox" class="MSearchBoxInactive">
        <span class="left">
          <img id="MSearchSelect" src="search/mag_sel.png"
               onmouseover="return searchBox.OnSearchSelectShow()"
               onmouseout="return searchBox.OnSearchSelectHide()"
               alt=""/>
          <input type="text" id="MSearchField" value="Search" accesskey="S"
               onfocus="searchBox.OnSearchFieldFocus(true)" 
               onblur="searchBox.OnSearchFieldFocus(false)" 
               onkeyup="searchBox.OnSearchFieldChange(event)"/>
          </span><span class="right">
            <a id="MSearchClose" href="javascript:searchBox.CloseResultsWindow()"><img id="MSearchCloseImg" border="0" src="search/close.png" alt=""/></a>
          </span>
        </div>
      </li>
    </ul>
  </div>
  <div id="navrow2" class="tabs2">
    <ul class="tablist">
      <li><a href="files.html"><span>File&#160;List</span></a></li>
    </ul>
  </div>
</div>
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
     onmouseover="return searchBox.OnSearchSelectShow()"
     onmouseout="return searchBox.OnSearchSelectHide()"
     onkeydown="return searchBox.OnSearchSelectKey(event)">
<a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(0)"><span class="SelectionMark">&#160;</span>All</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(1)"><span class="SelectionMark">&#160;</span>Classes</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(2)"><span class="SelectionMark">&#160;</span>Namespaces</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(3)"><span class="SelectionMark">&#160;</span>Files</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(4)"><span class="SelectionMark">&#160;</span>Functions</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(5)"><span class="SelectionMark">&#160;</span>Variables</a></div>

<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe src="javascript:void(0)" frameborder="0" 
        name="MSearchResults" id="MSearchResults">
</iframe>
</div>

<div class="header">
  <div class="headertitle">
<div class="title">D:/physi-tracklast/01/Android/PhysiTrack/src/helper/FileIOHelper.java</div>  </div>
</div><!--header-->
<div class="contents">
<a href="_file_i_o_helper_8java.html">Go to the documentation of this file.</a><div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 
<a name="l00002"></a>00002 
<a name="l00005"></a><a class="code" href="namespacehelper.html">00005</a> <span class="keyword">package </span>helper;
<a name="l00006"></a>00006 <span class="keyword">import</span> image.Analyzer;
<a name="l00007"></a>00007 
<a name="l00008"></a>00008 <span class="keyword">import</span> java.io.BufferedReader;
<a name="l00009"></a>00009 <span class="keyword">import</span> java.io.BufferedWriter;
<a name="l00010"></a>00010 <span class="keyword">import</span> java.io.File;
<a name="l00011"></a>00011 <span class="keyword">import</span> java.io.FileReader;
<a name="l00012"></a>00012 <span class="keyword">import</span> java.io.FileWriter;
<a name="l00013"></a>00013 <span class="keyword">import</span> java.io.IOException;
<a name="l00014"></a>00014 <span class="keyword">import</span> java.util.LinkedList;
<a name="l00015"></a>00015 <span class="keyword">import</span> java.util.ListIterator;
<a name="l00016"></a>00016 
<a name="l00017"></a>00017 <span class="keyword">import</span> android.os.Environment;
<a name="l00018"></a>00018 
<a name="l00020"></a><a class="code" href="classhelper_1_1_file_i_o_helper.html">00020</a> <span class="keyword">public</span> <span class="keyword">class </span><a class="code" href="classhelper_1_1_file_i_o_helper.html">FileIOHelper</a> {
<a name="l00021"></a>00021 
<a name="l00022"></a><a class="code" href="classhelper_1_1_file_i_o_helper.html#a1e1ee91b0534013ded1a6dafbc57be77">00022</a>         <span class="keyword">private</span> <span class="keyword">static</span> String <a class="code" href="classhelper_1_1_file_i_o_helper.html#a1e1ee91b0534013ded1a6dafbc57be77">path</a>;
<a name="l00023"></a>00023 
<a name="l00024"></a>00024         
<a name="l00025"></a><a class="code" href="classhelper_1_1_file_i_o_helper.html#ac57a540a93e5542a5792c3c565abf0fd">00025</a>         <span class="keyword">public</span> <span class="keyword">static</span> <span class="keywordtype">void</span> <a class="code" href="classhelper_1_1_file_i_o_helper.html#ac57a540a93e5542a5792c3c565abf0fd">newFolder</a>(String <a class="code" href="classhelper_1_1_file_i_o_helper.html#ac57a540a93e5542a5792c3c565abf0fd">newFolder</a>) {
<a name="l00026"></a>00026                 String extStorageDirectory = Environment.getExternalStorageDirectory()
<a name="l00027"></a>00027                                 .toString();
<a name="l00028"></a>00028                 File myNewFolder = <span class="keyword">new</span> File(extStorageDirectory + newFolder);
<a name="l00029"></a>00029                 myNewFolder.mkdir();
<a name="l00030"></a>00030                 <a class="code" href="classhelper_1_1_file_i_o_helper.html#a1e1ee91b0534013ded1a6dafbc57be77">path</a> = <span class="stringliteral">&quot;mnt/sdcard/&quot;</span> + newFolder + <span class="stringliteral">&quot;/&quot;</span>;
<a name="l00031"></a>00031         }
<a name="l00032"></a>00032 
<a name="l00033"></a><a class="code" href="classhelper_1_1_file_i_o_helper.html#a3d8f7c5f530b9e68a9495ca6f0e25e67">00033</a>         <span class="keyword">public</span> <span class="keyword">static</span> <span class="keywordtype">void</span> <a class="code" href="classhelper_1_1_file_i_o_helper.html#a3d8f7c5f530b9e68a9495ca6f0e25e67">writeToFile</a>(String name, <a class="code" href="classimage_1_1_analyzer.html">Analyzer</a> analyzer, <span class="keywordtype">int</span> w, <span class="keywordtype">int</span> h)
<a name="l00034"></a>00034                         <span class="keywordflow">throws</span> IOException {
<a name="l00035"></a>00035                 File file = <span class="keyword">new</span> File(<a class="code" href="classhelper_1_1_file_i_o_helper.html#a1e1ee91b0534013ded1a6dafbc57be77">path</a> + name + <span class="stringliteral">&quot;.txt&quot;</span>);
<a name="l00036"></a>00036 
<a name="l00037"></a>00037                 FileWriter fw = <span class="keyword">new</span> FileWriter(file);
<a name="l00038"></a>00038                 BufferedWriter out = <span class="keyword">new</span> BufferedWriter(fw);
<a name="l00039"></a>00039                 LinkedList&lt;double[]&gt; data;
<a name="l00040"></a>00040                 data = analyzer.getData();
<a name="l00041"></a>00041                 out.write(w + <span class="stringliteral">&quot; &quot;</span> + h + <span class="stringliteral">&quot;\n&quot;</span>);
<a name="l00042"></a>00042                 <span class="keywordflow">for</span> (ListIterator&lt;<span class="keywordtype">double</span>[]&gt; it = data.listIterator(); it.hasNext();) {
<a name="l00043"></a>00043                         <span class="keywordtype">double</span> v[] = it.next();
<a name="l00044"></a>00044                         <span class="keywordflow">for</span> (<span class="keywordtype">int</span> j = 0; j &lt; 5; j++) {
<a name="l00045"></a>00045                                 out.write(v[j] + <span class="stringliteral">&quot; &quot;</span>);
<a name="l00046"></a>00046                         }
<a name="l00047"></a>00047                         out.write(<span class="stringliteral">&quot;\n&quot;</span>);
<a name="l00048"></a>00048                 }
<a name="l00049"></a>00049 
<a name="l00050"></a>00050                 out.close();
<a name="l00051"></a>00051         }
<a name="l00052"></a>00052 
<a name="l00053"></a><a class="code" href="classhelper_1_1_file_i_o_helper.html#a02340d2d89e95956f550b2c5fc99d0a7">00053</a>         <span class="keyword">public</span> <span class="keyword">static</span> String <a class="code" href="classhelper_1_1_file_i_o_helper.html#a02340d2d89e95956f550b2c5fc99d0a7">getFullPath</a>(String name) {
<a name="l00054"></a>00054                 <span class="keywordflow">return</span> <a class="code" href="classhelper_1_1_file_i_o_helper.html#a1e1ee91b0534013ded1a6dafbc57be77">path</a> + name + <span class="stringliteral">&quot;.txt&quot;</span>;
<a name="l00055"></a>00055         }
<a name="l00056"></a>00056 
<a name="l00057"></a><a class="code" href="classhelper_1_1_file_i_o_helper.html#ab1431184f60ef0c8ab71b48d9f4a3045">00057</a>         <span class="keyword">public</span> <span class="keyword">static</span> LinkedList&lt;double[]&gt; <a class="code" href="classhelper_1_1_file_i_o_helper.html#ab1431184f60ef0c8ab71b48d9f4a3045">resultFromFile</a>(String fileName)
<a name="l00058"></a>00058                         <span class="keywordflow">throws</span> NumberFormatException, IOException {
<a name="l00059"></a>00059                 File txt = <span class="keyword">new</span> File(fileName);
<a name="l00060"></a>00060                 FileReader fr = <span class="keyword">new</span> FileReader(txt);
<a name="l00061"></a>00061                 BufferedReader in = <span class="keyword">new</span> BufferedReader(fr);
<a name="l00062"></a>00062 
<a name="l00063"></a>00063                 LinkedList&lt;double[]&gt; result = <span class="keyword">new</span> LinkedList&lt;double[]&gt;();
<a name="l00064"></a>00064                 String line;
<a name="l00065"></a>00065                 String[] temp = in.readLine().split(<span class="stringliteral">&quot; &quot;</span>);
<a name="l00066"></a>00066                 <span class="keywordtype">double</span>[] TEMP = <span class="keyword">new</span> <span class="keywordtype">double</span>[2];
<a name="l00067"></a>00067                 TEMP[0] = Double.parseDouble(temp[0]);
<a name="l00068"></a>00068                 TEMP[1] = Double.parseDouble(temp[1]);
<a name="l00069"></a>00069                 result.offer(TEMP);
<a name="l00070"></a>00070                 <span class="keywordflow">while</span> ((line = in.readLine()) != null) {
<a name="l00071"></a>00071                         String[] sor = line.split(<span class="stringliteral">&quot; &quot;</span>);
<a name="l00072"></a>00072                         <span class="keywordtype">double</span>[] nrline = <span class="keyword">new</span> <span class="keywordtype">double</span>[5];
<a name="l00073"></a>00073                         <span class="keywordflow">for</span> (<span class="keywordtype">int</span> j = 0; j &lt; 5; j++) {
<a name="l00074"></a>00074                                 nrline[j] = Double.parseDouble(sor[j]);
<a name="l00075"></a>00075                         }
<a name="l00076"></a>00076                         result.offer(nrline);
<a name="l00077"></a>00077                 }
<a name="l00078"></a>00078 
<a name="l00079"></a>00079                 in.close();
<a name="l00080"></a>00080                 <span class="keywordflow">return</span> result;
<a name="l00081"></a>00081         }
<a name="l00082"></a>00082 }
</pre></div></div><!-- contents -->


<hr class="footer"/><address class="footer"><small>
Generated on Fri Jun 8 2012 00:07:22 for PhysiTrack by &#160;<a href="http://www.doxygen.org/index.html">
<img class="footer" src="doxygen.png" alt="doxygen"/>
</a> 1.8.0
</small></address>

</body>
</html>
